\section{NFutil Namespace Reference}
\label{namespaceNFutil}\index{NFutil@{NFutil}}


\subsection{Detailed Description}
General utility functions for NFsim, including a random number generator and a function parser. 

\begin{Desc}
\item[Author:]Michael Sneddon \end{Desc}




\subsection*{Functions}
\begin{CompactItemize}
\item 
double {\bf convertToDouble} (const std::string \&s)
\begin{CompactList}\small\item\em Parses and converts std::string objects to double values. \item\end{CompactList}\item 
int {\bf convertToInt} (const std::string \&s)
\begin{CompactList}\small\item\em Parses and converts std::string objects to int values. \item\end{CompactList}\item 
void {\bf SEED\_\-RANDOM} (unsigned long seed)
\begin{CompactList}\small\item\em Seeds the random number generator used in all simulations. \item\end{CompactList}\item 
double {\bf RANDOM} (double max)
\begin{CompactList}\small\item\em Uniform random number on the interval (0,max]. \item\end{CompactList}\item 
double {\bf RANDOM\_\-CLOSED} ()
\begin{CompactList}\small\item\em Uniform random number on the interval (0,1). \item\end{CompactList}\item 
int {\bf RANDOM\_\-INT} (unsigned long min, unsigned long max)
\begin{CompactList}\small\item\em Uniform random number on the interval [min,max]. \item\end{CompactList}\item 
double {\bf RANDOM\_\-GAUSSIAN} ()
\begin{CompactList}\small\item\em Normally distributed random number with mean 0 and variance 1. \item\end{CompactList}\end{CompactItemize}
\subsection*{Variables}
\begin{CompactItemize}
\item 
const double {\bf PI} = 3.14159265358979323846
\item 
const double {\bf NA} = 6.02214179e23
\end{CompactItemize}


\subsection{Function Documentation}
\index{NFutil@{NFutil}!convertToDouble@{convertToDouble}}
\index{convertToDouble@{convertToDouble}!NFutil@{NFutil}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double NFutil::convertToDouble (const std::string \& {\em s})}\label{namespaceNFutil_38a3561b6d4c91d18cf25f8671c02bee}


Parses and converts std::string objects to double values. 

Just uses the standard library operations for converting strings to double values. Throws a run time exception if the parse failed. \begin{Desc}
\item[Author:]Michael Sneddon \end{Desc}
\index{NFutil@{NFutil}!convertToInt@{convertToInt}}
\index{convertToInt@{convertToInt}!NFutil@{NFutil}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int NFutil::convertToInt (const std::string \& {\em s})}\label{namespaceNFutil_051f474d6efe9f1c4ab524203d834666}


Parses and converts std::string objects to int values. 

Just uses the standard library operations for converting strings to integers. Throws a run time exception if the parse failed. \begin{Desc}
\item[Author:]Michael Sneddon \end{Desc}
\index{NFutil@{NFutil}!RANDOM@{RANDOM}}
\index{RANDOM@{RANDOM}!NFutil@{NFutil}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double NFutil::RANDOM (double {\em max})}\label{namespaceNFutil_e6442caf2765cab2d72c6655ca93a09f}


Uniform random number on the interval (0,max]. 

This function returns a random double on the half open interval (0,max]. This is important for selecting the next reaction to fire because we want the value to always be greater than zero, but the value can equal the max value. \begin{Desc}
\item[Author:]Michael Sneddon \end{Desc}
\index{NFutil@{NFutil}!RANDOM\_\-CLOSED@{RANDOM\_\-CLOSED}}
\index{RANDOM\_\-CLOSED@{RANDOM\_\-CLOSED}!NFutil@{NFutil}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double NFutil::RANDOM\_\-CLOSED ()}\label{namespaceNFutil_4ef4619c47b661fddc278f317c6a2347}


Uniform random number on the interval (0,1). 

This function returns a random double on the closed interval (0,1). This is important for choosing the next dt in the simulation because we will take the log of this number and we don't want dt=0 or dt=infinity. \begin{Desc}
\item[Author:]Michael Sneddon \end{Desc}
\index{NFutil@{NFutil}!RANDOM\_\-GAUSSIAN@{RANDOM\_\-GAUSSIAN}}
\index{RANDOM\_\-GAUSSIAN@{RANDOM\_\-GAUSSIAN}!NFutil@{NFutil}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double NFutil::RANDOM\_\-GAUSSIAN ()}\label{namespaceNFutil_eb10c0c97bb034ea4ea1d206fad3ba70}


Normally distributed random number with mean 0 and variance 1. 

Returns a normally distributed random number. Based on the java implementation of \doxyref{Random.nextGaussian}{p.}{random_8cpp_0a52667c2e0e040b5dc629bf5ec51c35}, this method uses the polar method of G. E. P. Box, M. E. Muller, and G. Marsaglia, as described by Donald E. Knuth in The Art of Computer Programming, Volume 2: Seminumerical Algorithms, section 3.4.1, subsection C, algorithm P. \begin{Desc}
\item[Author:]Michael Sneddon \end{Desc}
\index{NFutil@{NFutil}!RANDOM\_\-INT@{RANDOM\_\-INT}}
\index{RANDOM\_\-INT@{RANDOM\_\-INT}!NFutil@{NFutil}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int NFutil::RANDOM\_\-INT (unsigned long {\em min}, unsigned long {\em max})}\label{namespaceNFutil_d54f1800d7851854eca0d1e8782cdbfc}


Uniform random number on the interval [min,max]. 

This is a multipurpose function that selects a random number on the half open interval [min, max). This allows you to quickly select a random element from a list of known size. The function call would look something like: RANDOM\_\-INT(0,sizeOfList). This is used to select the next molecule to be included in a reaction. \begin{Desc}
\item[Author:]Michael Sneddon \end{Desc}
\index{NFutil@{NFutil}!SEED\_\-RANDOM@{SEED\_\-RANDOM}}
\index{SEED\_\-RANDOM@{SEED\_\-RANDOM}!NFutil@{NFutil}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void NFutil::SEED\_\-RANDOM (unsigned long {\em seed})}\label{namespaceNFutil_32bb1e1aa05fae35e78c861da347c20f}


Seeds the random number generator used in all simulations. 

Seed the random number generator with a positive 32bit integer If you don't call this function, the current time will be used as a seed so each run will be different. \begin{Desc}
\item[Author:]Michael Sneddon \end{Desc}


\subsection{Variable Documentation}
\index{NFutil@{NFutil}!NA@{NA}}
\index{NA@{NA}!NFutil@{NFutil}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}const double {\bf NFutil::NA} = 6.02214179e23}\label{namespaceNFutil_c8aca8d5c189b6ce5a905a119d8cfc7e}


\index{NFutil@{NFutil}!PI@{PI}}
\index{PI@{PI}!NFutil@{NFutil}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}const double {\bf NFutil::PI} = 3.14159265358979323846}\label{namespaceNFutil_236b7d6cb660212fcfea6ce6629ebd24}


